/*
Project: 		The Impact of Short-Term Employment for Low-Income Youth: Experimental 	
				Evidence from the Philippines
Authors: 		Emily A. Beam and Stella Quimbo


***********************************
Path: 			code/02_analysis
File name: 		table_03_05_06.do 
***********************************

Purpose: 		Generates Tables 3, 5, 6 and associated appendix tables for results on employment, education and employment/education

Inputs: 		spes_data.dta
Outputs: 			table`tnemp'_iv_`mes'			*Table 3 = table3_ivspes_panel.tex
					table`tneduc'_iv_`mes'			*Table 5 = table5_ivspes_panel.tex
					table`tneduemp'_iv_`mes'		*Table 6 = table6_ivspes_panel.tex
																					
											* ITT specifications (appendix)
					table`tnemp'_itt				* Table B1 = table3_itt_panel.tex
					table`tneduc'_itt				* Table B2 = table5_itt_panel.tex
					table`tneduemp'_itt				* Table B3 = table6_itt_panel.tex
																					
											* LATE specifications, admin data (appendix)
					table`tnemp'_iv_`mes'			* Table B5 = table3_ivtr_panel.tex
					table`tneduc'_iv_`mes'			* Table B6 = table5_ivtr_panel.tex
					table`tneduemp'_iv_`mes'		* Table B7 = table6_ivtr_panel.tex

Log: 			results/03_output/log_table_03_05_06.log		

Last updated: 	16 November 2021
*/ 



cap log close 

log using "$output/log_table_03_05_06.log",replace


use "$usedata_analysis/spes_data",clear 
	keep if endline == 1




local l_bb_female "Female"
local l_NT_edu "College"

local intlist "_bb_female _NT_edu"

local n: word count $cov1
	assert `n' == 18 

** Interaction terms 

foreach interact in  `intlist' {
	
	foreach mes in tr spes_2016{
gen `mes'X`interact' = `mes'*`interact'
label var `mes'X`interact' "SPES X `l`interact''"

	}

assert !missing(`interact')

gen `interact'xtreatment = `interact'*treatment
label var `interact'xtreatment "SPES X `l`interact''"


* Generate inteaction terms for each covariate 

ds $cov1 
foreach cov in `r(varlist)'{ 
gen `interact'X`cov' = `cov'*`interact'
} 

}



* Set locals 
local depvar1 	_eeo_worknow 		_eeo_jobsearch 			_eeo_wage_mn 		_eeo_workhours  			
local labels1 "	"Currently working (formal)" 	"Looked for work since 2016" 		"Currently earning"  			"Work hours weekly now" "
					

local depvar2 	_eeo_emped 		_eeo_noemped 			_eeo_empnoed 		_eeo_noempnoed  			
local labels2 "	"Enrolled and working" 	"Enrolled, not working" 		"Not enrolled, working"  			"Not enrolled, not working" "
						
local depvar3 _eeo_enroll  _eeo_enr_ny _eeo_gwan _eeo_at
local labels3 " "Currently Enrolled"  "Enroll next year"  "Normalized GWA" " Academic Track""


										
loc w = 1				
local name1 "employment" 
local name2 "employment-ed"
local name3 "educ"

forval j = 1/3{		
					

local r replace



** Uninteracted version ** 
	foreach var in `depvar`j'' {
	
qui		areg `var' treatment $cov1 if treatment!=. ,r absorb(scel)
	
			estimates store pa`var'
		summ `var' if treatment==0 
			estadd scalar dmean = `r(mean)'
			
foreach mes in tr spes_2016{

		xi:  ivregress 2sls  `var' (`mes' = treatment ) $cov1  i.scel if treatment!=. ,  robust
		estimates store iv`mes'`var'
		summ `var' if treatment==0 
		estadd scalar dmean = `r(mean)'


}
	
	}
	foreach var in `depvar`j'' {



foreach interact in `intlist'  {


		qui areg `var' treatment `interact'xtreatment $cov1 if treatment != . & _f`interact' == 0  ,r absorb(scel)
	
		estimates store pa`var'`interact'
		summ `var' if treatment==0 
		estadd scalar dmean = `r(mean)'
		test treatment + `interact'xtreatment == 0 
		estadd scalar pvalint = `r(p)'
		
		
		
foreach mes in tr spes_2016{

	
		xi:  ivregress 2sls  `var' (`mes' `mes'X`interact' = treatment `interact'xtreatment) $cov1 `interact'X* i.scel if treatment!=. & _f`interact' == 0,  robust
		
		estimates store iv`mes'`w'`interact'
		di in red "estimates stored as iv`mes'`w'`interact'"
		summ `var' if treatment==0 
		estadd scalar dmean = `r(mean)'
		
		test `mes' + `mes'X`interact' == 0 
		local pval = `r(p)'
		estadd scalar pvalint = `r(p)'
}	// nature of IV loop
		

	
	}		// interaction term
	
	local w = `w' + 1
}		// individual dependent variables within each set
	
}		// dependent variable sets (tables)	

		


********************************************
********************************************


** Table numbers 

loc tneduemp = 6	// education and employment
loc tnemp = 3		//  employment 
loc tneduc = 5		// education 

*** Footnote text 



local fn`tneduemp' = "\multicolumn{5}{p{\textwidth}}{\footnotesize{Notes: All endline respondents included. All specifications include controls listed in Table \ref{tbal} along with stratification-cell fixed effects.  Panels B and C add controls multiplied by the binary interaction term along with uninteracted stratification-cell fixed effects. \textit{*** p$<$0.01, ** p$<$0.05, * p$<$0.10} }}\\"

local fn`tnemp' = "\multicolumn{5}{p{\textwidth}}{\footnotesize{Notes: All endline respondents included. All specifications include controls listed in Table \ref{tbal} along with stratification-cell fixed effects. Panels B and C add controls multiplied by the binary interaction term along with uninteracted stratification-cell fixed effects. \textit{*** p$<$0.01, ** p$<$0.05, * p$<$0.10} }}\\"

local fn`tneduc' = "\multicolumn{5}{p{\textwidth}}{\footnotesize{Notes: All endline respondents included, column 4 restricted to students enrolled in grade 11 and 12.  Grade-weighted average normalized using education-level and scale-specific means and standard deviations of the control group. All specifications include controls listed in Table \ref{tbal} along with stratification-cell fixed effects. Panels B and C add controls multiplied by the binary interaction term along with uninteracted stratification-cell fixed effects. \textit{*** p$<$0.01, ** p$<$0.05, * p$<$0.10} }}\\"

********************************************
********************************************
cd "$tables_analysis"
#delimit ; 
********** Table 3 - employment  *************;
{;
	
	
	// Output Tables ;

	esttab pa_eeo_worknow 		pa_eeo_jobsearch 			pa_eeo_wage_mn 		pa_eeo_workhours  			  
	using table`tnemp'_itt.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats() noobs
	keep(treatment) label  
	varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant)  collabels(none)
	mlabels(	"Currently working (formal)" "Looked for work" 
				"Current monthly earnings"   "Work hours weekly now" , 
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	prehead( "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) 
	prefoot() 
	postfoot("\bottomrule" );
	
foreach mes in tr spes_2016{;
	
	esttab iv`mes'_eeo_worknow 		iv`mes'_eeo_jobsearch 			iv`mes'_eeo_wage_mn 		iv`mes'_eeo_workhours  	
	using table`tnemp'_iv_`mes'.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats() noobs
	keep(`mes') label  
	varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant) 
	mlabels("Currently working (formal)" "Looked for work" 
			"Current monthly earnings"  	"Work hours weekly now" , 
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead( "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) 
	prefoot() 
	postfoot("\bottomrule");
};




	//* Panel B Female;
	esttab pa_eeo_worknow_bb_female	pa_eeo_jobsearch_bb_female 	pa_eeo_wage_mn_bb_female 	pa_eeo_workhours_bb_female
	using table`tnemp'_itt_bb_female.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats( pvalint , fmt(%9.3f  )  
	labels(  "p-value, SPES + SPES X Female" )) 
	keep(treatment _bb_femalextreatment) label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant) 
	mlabels(	"Currently working (formal)" 	"Looked for work" 		
				"Current monthly earnings" 			"Work hours weekly now" , 
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(}))  
	collabels(none)
	prehead(  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule"  );
	
foreach mes in tr spes_2016{;

	esttab iv`mes'1_bb_female 		iv`mes'2_bb_female		iv`mes'3_bb_female		iv`mes'4_bb_female  			  
	using table`tnemp'_iv_`mes'_bb_female.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats( pvalint , fmt(%9.3f  )  
	labels(  "p-value, SPES + SPES X Female")) 
	keep(`mes' `mes'X_bb_female) label  
	varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant) 
	mlabels("Currently working (formal)" 	"Looked for work" 	
			"Current monthly earnings" 	"Work hours weekly now" , 
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead("\begin{table}\caption{@title}" "\begin{center}"  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) 
	prefoot() 
	postfoot("\bottomrule"  );
};
	//* Panel C Education ;
	esttab pa_eeo_worknow_NT_edu 	pa_eeo_jobsearch_NT_edu 		pa_eeo_wage_mn_NT_edu		pa_eeo_workhours_NT_edu
	using table`tnemp'_itt_NT_edu.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats(pvalint N   dmean, fmt(%9.3f %9.0f %9.3f )  
	labels("p-value, SPES + SPES X College" "Observations"   "Mean, control group")) 
	keep(treatment _NT_eduxtreatment) label  
	varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant) 
	mlabels(	"Currently working (formal)" 	"Looked for work" 	
				"Current monthly earnings" 			"Work hours weekly now" , 
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(}))  
	collabels(none)
	prehead(  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule" "`fn`tnemp''" "\end{tabular}" );
	
foreach mes in tr spes_2016{;

	esttab iv`mes'1_NT_edu		iv`mes'2_NT_edu 			iv`mes'3_NT_edu		iv`mes'4_NT_edu  			  
	using table`tnemp'_iv_`mes'_NT_edu.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats(pvalint N   dmean, fmt(%9.3f  %9.0f %9.3f )  
	labels( "p-value, SPES + SPES X College" "Observations"  "Mean, control group")) 
	keep(`mes' `mes'X_NT_edu) label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant) 
	mlabels("Currently working (formal)" 	"Looked for work" 	
			"Current monthly earnings"  			"Work hours weekly now" ,
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead("\begin{table}\caption{@title}" "\begin{center}"  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule" "`fn`tnemp''" "\end{tabular}" );
};






// Combine panels ;


include "$dofiles/PanelCombine.do";

// Table 3  - ITT;
panelcombine, use(table`tnemp'_itt.tex table`tnemp'_itt_bb_female.tex table`tnemp'_itt_NT_edu.tex)  
columncount(5) paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") 
save(table`tnemp'_itt_panel.tex) cleanup ;



// Table 3  - IV - Admin;
panelcombine, use(table`tnemp'_iv_tr.tex table`tnemp'_iv_tr_bb_female.tex table`tnemp'_iv_tr_NT_edu.tex)  
columncount(5) paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") 
save(table`tnemp'_ivtr_panel.tex) cleanup;



// Table 3  - IV - self report ;
panelcombine, use(table`tnemp'_iv_spes_2016.tex table`tnemp'_iv_spes_2016_bb_female.tex table`tnemp'_iv_spes_2016_NT_edu.tex)  
columncount(5)  paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") 
save(table`tnemp'_ivspes_panel.tex) cleanup;


};

#delimit ;

********** Table 5 - education  *************;
{;
	
	#delimit ; 
	// Output Tables ;

	esttab pa_eeo_enroll 		pa_eeo_enr_ny 			pa_eeo_gwan		pa_eeo_at 			  
	using table`tneduc'_itt.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	keep(treatment) label  noobs 
	varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on education\label{teduc}) 
	varlabels(_cons Constant) 
	mlabels("Enrolled in school" "Will enroll, 2017-18" "Grade-Weighted Average" "Academic track, SHS only",
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead( "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) 
	prefoot() 
	postfoot("\bottomrule" );
	
foreach mes in tr spes_2016{;
	
	esttab iv`mes'_eeo_enroll 		iv`mes'_eeo_enr_ny 		iv`mes'_eeo_gwan		iv`mes'_eeo_at	
	using table`tneduc'_iv_`mes'.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	keep(`mes') label  noobs
	varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on education\label{teduc}) 
	varlabels(_cons Constant) 
	mlabels("Enrolled in school" "Will enroll, 2017-18" "Grade-Weighted Average" "Academic track, SHS only",
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead( "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) 
	prefoot() 
	postfoot("\bottomrule");
};


	//* Panel B Female;
	esttab pa_eeo_enroll_bb_female 	pa_eeo_enr_ny_bb_female 	pa_eeo_gwan_bb_female pa_eeo_at_bb_female 
	using table`tneduc'_itt_bb_female.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats( pvalint , fmt(%9.3f )  
	labels(  "p-value, SPES + SPES X Female" )) 
	keep(treatment _bb_femalextreatment) label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on education\label{teduc}) 
	varlabels(_cons Constant) 
	mlabels("Enrolled in school" "Will enroll, 2017-18" "Grade-Weighted Average" "Academic track, SHS only",
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(}))  
	collabels(none)
	prehead(  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule"  );
	
foreach mes in tr spes_2016{;

	esttab iv`mes'9_bb_female 		iv`mes'10_bb_female		iv`mes'11_bb_female		iv`mes'12_bb_female  			  
	using table`tneduc'_iv_`mes'_bb_female.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats( pvalint, fmt(%9.3f  )  
	labels(  "p-value, SPES + SPES X Female" )) 
	keep(`mes' `mes'X_bb_female) label  
	varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on education\label{teduc}) 
	varlabels(_cons Constant) 
	mlabels("Enrolled in school" "Will enroll, 2017-18" "Grade-Weighted Average" "Academic track, SHS only",
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead("\begin{table}\caption{@title}" "\begin{center}"  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) 
	prefoot() 
	postfoot("\bottomrule"  );
};
	//* Panel C Education ;
	esttab pa_eeo_enroll_NT_edu 	pa_eeo_enr_ny_NT_edu 	pa_eeo_gwan_NT_edu  
	using table`tneduc'_itt_NT_edu.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats( pvalint N dmean , fmt(%9.3f %9.0f  %9.3f )  
	labels( "p-value, SPES + SPES X College" "Observations" "Mean, control group" )) 
	keep(treatment _NT_eduxtreatment) label  
	varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on education\label{teduc}) 
	varlabels(_cons Constant) 
	mlabels("Enrolled in school" "Will enroll, 2017-18" "Grade-Weighted Average" "Academic track, SHS only",
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(}))  
	collabels(none)
	prehead("\begin{table}\caption{@title}" "\begin{center}"  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule" "`fn`tneduc''" "\end{tabular}" );
	
foreach mes in tr spes_2016{;

	esttab iv`mes'9_NT_edu		iv`mes'10_NT_edu 			iv`mes'11_NT_edu		  			  
	using table`tneduc'_iv_`mes'_NT_edu.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats(pvalint N dmean , fmt(%9.3f %9.0f %9.3f )  
	labels("p-value, SPES + SPES X College" "Observations" "Mean, control group" )) 
	keep(`mes' `mes'X_NT_edu) label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on education\label{teduc}) 
	varlabels(_cons Constant) 
	mlabels("Enrolled in school" "Will enroll, 2017-18" "Grade-Weighted Average" "Academic track, SHS only",
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead("\begin{table}\caption{@title}" "\begin{center}"  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule" "`fn`tneduc''" "\end{tabular}" );
};





// Table 5  - ITT ;

panelcombine, use(table`tneduc'_itt.tex table`tneduc'_itt_bb_female.tex table`tneduc'_itt_NT_edu.tex)  
columncount(5) paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") 
save(table`tneduc'_itt_panel.tex) cleanup;



// Table 5  - IV - Admin ;

panelcombine, use(table`tneduc'_iv_tr.tex table`tneduc'_iv_tr_bb_female.tex table`tneduc'_iv_tr_NT_edu.tex)  
columncount(5) paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") 
save(table`tneduc'_ivtr_panel.tex) cleanup;



// Table 5  - IV - self report ;

panelcombine, use(table`tneduc'_iv_spes_2016.tex table`tneduc'_iv_spes_2016_bb_female.tex table`tneduc'_iv_spes_2016_NT_edu.tex)  
columncount(5)  paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") 
save(table`tneduc'_ivspes_panel.tex) cleanup;


};

#delimit ;
********** Table 6 - education/ed *************;
{;
	// Output Tables ;



	esttab pa_eeo_emped 		pa_eeo_noemped 			pa_eeo_empnoed 		pa_eeo_noempnoed    			  
	using table`tneduemp'_itt.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	keep(treatment) label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant) noobs
	mlabels(	"Enrolled and working" 	"Enrolled, not working" 	
				"Not enrolled, working"  			"Not enrolled, not working", 
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead( "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule" );
	
foreach mes in tr spes_2016{;
	
	esttab iv`mes'_eeo_emped 		iv`mes'_eeo_noemped			iv`mes'_eeo_empnoed 		iv`mes'_eeo_noempnoed
	using table`tneduemp'_iv_`mes'.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") noobs 
	keep(`mes') label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant) 
	mlabels("Enrolled and working" 	"Enrolled, not working" 	
			"Not enrolled, working"  			"Not enrolled, not working" , 
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	collabels(none) 
	prehead( "\begin{tabular}{lcccc}" "\toprule") posthead(\hline) prefoot() postfoot("\bottomrule");
};




	//* Panel B Female;
	esttab pa_eeo_emped_bb_female		pa_eeo_noemped_bb_female 			pa_eeo_empnoed_bb_female 		pa_eeo_noempnoed_bb_female  			  
	using table`tneduemp'_itt_bb_female.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats( pvalint , fmt(%9.3f  )  
	labels(  "p-value, SPES + SPES X Female")) 
	keep(treatment _bb_femalextreatment) 
	label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) varlabels(_cons Constant) 
	mlabels(	"Enrolled and working" 	"Enrolled, not working" 	
				"Not enrolled, working"  			"Not enrolled, not working" , 
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(}))  
	collabels(none)
	prehead(  "\begin{tabular}{lcccc}" "\toprule") posthead(\hline) prefoot() postfoot("\bottomrule"  );
	
foreach mes in tr spes_2016{;

	esttab iv`mes'5_bb_female 		iv`mes'6_bb_female		iv`mes'7_bb_female		iv`mes'8_bb_female  			  using 
	table`tneduemp'_iv_`mes'_bb_female.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats( pvalint , fmt(%9.3f  )  
	labels(  "p-value, SPES + SPES X Female")) 
	keep(`mes' `mes'X_bb_female) label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) 
	varlabels(_cons Constant) 
	mlabels("Enrolled and working" 				"Enrolled, not working" 		
			"Not enrolled, working"  			"Not enrolled, not working", 
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	prehead("\begin{table}\caption{@title}" "\begin{center}"  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule"  );
};
	//* Panel C Education ;
	esttab pa_eeo_emped_NT_edu 		pa_eeo_noemped_NT_edu 			pa_eeo_empnoed_NT_edu		pa_eeo_noempnoed_NT_edu 			  using table`tneduemp'_itt_NT_edu.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats( pvalint N dmean , fmt( %9.3f %9.0f %9.3f )  
	labels("p-value, SPES + SPES X College" "Observations" "Mean, control group" )) 
	keep(treatment _NT_eduxtreatment) label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) varlabels(_cons Constant) 
	mlabels(	"Enrolled and working" 				"Enrolled, not working" 		
				"Not enrolled, working"  			"Not enrolled, not working" , 
				span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(}))  
	prehead(  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule" "`fn`tneduemp''" "\end{tabular}" );
	
foreach mes in tr spes_2016{;

	esttab iv`mes'5_NT_edu		iv`mes'6_NT_edu 			iv`mes'7_NT_edu		iv`mes'8_NT_edu  			  
	using table`tneduemp'_iv_`mes'_NT_edu.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats(pvalint N dmean , fmt(%9.3f %9.0f %9.3f  )  
	labels( "p-value, SPES + SPES X College" "Observations" "Mean, control group" )) 
	keep(`mes' `mes'X_NT_edu) label  varwidth(16) modelwidth(13) style(tex) 
	title(Impact of SPES on employment\label{temployment}) varlabels(_cons Constant) 
	mlabels("Enrolled and working" 	"Enrolled, not working" 		
			"Not enrolled, working"  			"Not enrolled, not working" , 
			span prefix(\multicolumn{@span}{x{0.15\textwidth}}{) suffix(})) 
	prehead("\begin{table}\caption{@title}" "\begin{center}"  "\begin{tabular}{lcccc}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule" "`fn`tneduemp''" "\end{tabular}" );
};




// Table 6  - ITT ;

panelcombine, use(table`tneduemp'_itt.tex table`tneduemp'_itt_bb_female.tex table`tneduemp'_itt_NT_edu.tex)  columncount(5) paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") save(table`tneduemp'_itt_panel.tex) cleanup
;


// Table 6  - IV - Admin ;

panelcombine, use(table`tneduemp'_iv_tr.tex table`tneduemp'_iv_tr_bb_female.tex table`tneduemp'_iv_tr_NT_edu.tex)  columncount(5) paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") save(table`tneduemp'_ivtr_panel.tex) cleanup;



// Table 6  - IV - self report ;

panelcombine, use(table`tneduemp'_iv_spes_2016.tex table`tneduemp'_iv_spes_2016_bb_female.tex table`tneduemp'_iv_spes_2016_NT_edu.tex)  columncount(5)  paneltitles("Aggregate treatment effects" "Interacted by gender" "Interacted by education level") save(table`tneduemp'_ivspes_panel.tex) cleanup ;


};



log close;

exit;
